// import Vue from 'vue'
// import Vuex from 'vuex'
// import moduleCart from '@/store/cart.js'
// Vue.use(Vuex)

// const store = new Vuex.Store({
//   modules: {
// 	  'm_cart':moduleCart
//   } 
// })
import { createStore } from 'vuex'
import moduleCart from '@/store/cart.js'
import moduleUser from '@/store/user1.js'
const store = createStore({
	
  state() {
    return {
      count: 0,
      userInfo: null
    }
	
  },
 
  
  mutations: {
    increment(state) {
      state.count++
    },
    setUserInfo(state, payload) {
      state.userInfo = payload
    }
  },
  actions: {
    incrementAsync({ commit }) {
      setTimeout(() => {
        commit('increment')
      }, 1000)
    },
    async fetchUser({ commit }, userId) {
      const user = await uni.request({
        url: `https://api.example.com/users/${userId}`
      })
      commit('setUserInfo', user)
    }
  },
  getters: {
    doubleCount(state) {
      return state.count * 2
    }
  },
  modules: {
  	  'm_cart':moduleCart,
	  'm_user':moduleUser
     } 
})

export default store
